#define _CRT_SECURE_NO_WARNINGS 1

#include <stdbool.h>
#include <stdio.h>

bool is_leap_year(int year)
{
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
    {
        return true;
    }
    return false;
}

int main()
{
    int month_days[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    int year, month, day, sum;
    while (scanf("%d %d %d", &year, &month, &day) != EOF)
    {
        if (is_leap_year(year))
        {
            month_days[2] = month_days[2] + 1;
            sum = day;
            for (int i = 0; i < month; i++)
            {
                sum += month_days[i];
            }
            printf("%d\n", sum);

        }
        else
        {
            sum = day;
            for (int i = 0; i < month; i++)
            {
                sum += month_days[i];
            }
            printf("%d\n", sum);

        }
    }
}